package Arrays方法;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

public class text2 {
    public static void main(String[] args) {
        int[] arr = {0, 1, 2, 3, 4, 5, 6, 7};
        String str = Arrays.toString(arr);
        System.out.println(str);

        for (int i : arr) {
            System.out.print(i + " ");
        }

        System.out.println();

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }

        System.out.println();

        List<Integer> list = new ArrayList<>();
        Integer[] arr1  = new Integer[arr.length];

        for (int i = 0; i < arr.length; i++) {
            arr1[i] = arr[i];
            list.add(arr1[i]);
        }

        System.out.println();

        for (Integer i : arr1) {
            System.out.print(i + " ");
        }

        System.out.println();
        System.out.println(list);//[0, 1, 2, 3, 4, 5, 6, 7]

        list.forEach(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.print(integer + " ");
            }
        });

        System.out.println();

        Iterator<Integer> it = list.iterator();
        while (it.hasNext()){
            Integer next = it.next();
            System.out.print(next + " ");
        }
    }
}
